/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*|
 * JDialogEntities.java
 *
 * Created on 26/04/2010, 23:29:24
 */
package systole.view.crud;

import java.awt.Color;
import javax.swing.JButton;
import javax.swing.ListSelectionModel;
import org.jdesktop.application.Action;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import systole.view.crud.controller.ControllerEntityView;

/**
 *
 * @author jmj
 */
public class JDialogEntities extends javax.swing.JDialog {

    /**
     *
     */
    private static final long serialVersionUID = -7075942614064623713L;
    private ControllerEntityView controllerEntityView;

    /** Creates new form JDialogEntities
     * @param parent
     * @param controllerEntityView
     */
    public JDialogEntities(java.awt.Frame parent, ControllerEntityView controllerEntityView) {
        super(parent, true);
        initComponents();
        this.controllerEntityView = controllerEntityView;
        this.jTableEntities.setModel(this.controllerEntityView.getEntityTableModel());
        this.jTableEntities.setSelectionBackground(Color.blue);
        this.jTableEntities.addMouseListener(new TabelMouseAdapter(controllerEntityView));
        this.jTableEntities.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.jXFindBar1.setSearchable(this.jTableEntities.getSearchable());
        this.jTableEntities.addHighlighter(HighlighterFactory.createSimpleStriping());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlCenter = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableEntities = new org.jdesktop.swingx.JXTable();
        jPnlTop = new javax.swing.JPanel();
        jXFindBar1 = new org.jdesktop.swingx.JXFindBar();
        jXEntityHeader = new org.jdesktop.swingx.JXHeader();
        jPnlLeftsearchBar = new javax.swing.JPanel();
        jPnlRigthSearchBar = new javax.swing.JPanel();
        jPnlBottom = new javax.swing.JPanel();
        jBtnClose = new javax.swing.JButton();
        jBtnRemove = new javax.swing.JButton();
        jBtnEdit = new javax.swing.JButton();
        jBtnNew = new javax.swing.JButton();
        jBtnSelect = new javax.swing.JButton();
        jPnlRigth = new javax.swing.JPanel();
        jPnlLeft = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setIconImage(null);
        setMinimumSize(new java.awt.Dimension(400, 400));
        setModal(true);
        setName("Form"); // NOI18N

        jPnlCenter.setName("jPnlCenter"); // NOI18N
        jPnlCenter.setPreferredSize(new java.awt.Dimension(500, 362));
        jPnlCenter.setLayout(new javax.swing.BoxLayout(jPnlCenter, javax.swing.BoxLayout.LINE_AXIS));

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTableEntities.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTableEntities.setColumnControlVisible(true);
        jTableEntities.setName("jTableEntities"); // NOI18N
        jTableEntities.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jTableEntities);

        jPnlCenter.add(jScrollPane1);

        getContentPane().add(jPnlCenter, java.awt.BorderLayout.CENTER);

        jPnlTop.setName("jPnlTop"); // NOI18N
        jPnlTop.setPreferredSize(new java.awt.Dimension(560, 100));
        jPnlTop.setLayout(new java.awt.BorderLayout());

        jXFindBar1.setName("jXFindBar1"); // NOI18N
        jPnlTop.add(jXFindBar1, java.awt.BorderLayout.CENTER);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JDialogEntities.class);
        jXEntityHeader.setBackground(resourceMap.getColor("jXEntityHeader.background")); // NOI18N
        jXEntityHeader.setName("jXEntityHeader"); // NOI18N
        jXEntityHeader.setPreferredSize(new java.awt.Dimension(160, 55));
        jXEntityHeader.setTitle(resourceMap.getString("jXEntityHeader.title")); // NOI18N
        jXEntityHeader.setTitleFont(jXEntityHeader.getTitleFont().deriveFont(jXEntityHeader.getTitleFont().getSize()+5f));
        jPnlTop.add(jXEntityHeader, java.awt.BorderLayout.NORTH);

        jPnlLeftsearchBar.setName("jPnlLeftsearchBar"); // NOI18N
        jPnlLeftsearchBar.setPreferredSize(new java.awt.Dimension(10, 50));

        javax.swing.GroupLayout jPnlLeftsearchBarLayout = new javax.swing.GroupLayout(jPnlLeftsearchBar);
        jPnlLeftsearchBar.setLayout(jPnlLeftsearchBarLayout);
        jPnlLeftsearchBarLayout.setHorizontalGroup(
            jPnlLeftsearchBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 10, Short.MAX_VALUE)
        );
        jPnlLeftsearchBarLayout.setVerticalGroup(
            jPnlLeftsearchBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 45, Short.MAX_VALUE)
        );

        jPnlTop.add(jPnlLeftsearchBar, java.awt.BorderLayout.WEST);

        jPnlRigthSearchBar.setName("jPnlRigthSearchBar"); // NOI18N

        javax.swing.GroupLayout jPnlRigthSearchBarLayout = new javax.swing.GroupLayout(jPnlRigthSearchBar);
        jPnlRigthSearchBar.setLayout(jPnlRigthSearchBarLayout);
        jPnlRigthSearchBarLayout.setHorizontalGroup(
            jPnlRigthSearchBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 10, Short.MAX_VALUE)
        );
        jPnlRigthSearchBarLayout.setVerticalGroup(
            jPnlRigthSearchBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 45, Short.MAX_VALUE)
        );

        jPnlTop.add(jPnlRigthSearchBar, java.awt.BorderLayout.EAST);

        getContentPane().add(jPnlTop, java.awt.BorderLayout.NORTH);

        jPnlBottom.setName("jPnlBottom"); // NOI18N
        jPnlBottom.setPreferredSize(new java.awt.Dimension(560, 60));
        jPnlBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 5, 10));

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getActionMap(JDialogEntities.class, this);
        jBtnClose.setAction(actionMap.get("closeForm")); // NOI18N
        jBtnClose.setIcon(resourceMap.getIcon("jBtnClose.icon")); // NOI18N
        jBtnClose.setText(resourceMap.getString("jBtnClose.text")); // NOI18N
        jBtnClose.setToolTipText(resourceMap.getString("jBtnClose.toolTipText")); // NOI18N
        jBtnClose.setName("jBtnClose"); // NOI18N
        jBtnClose.setPreferredSize(new java.awt.Dimension(110, 30));
        jPnlBottom.add(jBtnClose);

        jBtnRemove.setAction(actionMap.get("removeEntity")); // NOI18N
        jBtnRemove.setIcon(resourceMap.getIcon("jBtnRemove.icon")); // NOI18N
        jBtnRemove.setText(resourceMap.getString("jBtnRemove.text")); // NOI18N
        jBtnRemove.setName("jBtnRemove"); // NOI18N
        jBtnRemove.setPreferredSize(new java.awt.Dimension(110, 30));
        jPnlBottom.add(jBtnRemove);

        jBtnEdit.setAction(actionMap.get("edtiEntity")); // NOI18N
        jBtnEdit.setIcon(resourceMap.getIcon("jBtnEdit.icon")); // NOI18N
        jBtnEdit.setText(resourceMap.getString("jBtnEdit.text")); // NOI18N
        jBtnEdit.setName("jBtnEdit"); // NOI18N
        jBtnEdit.setPreferredSize(new java.awt.Dimension(110, 30));
        jPnlBottom.add(jBtnEdit);

        jBtnNew.setAction(actionMap.get("newEntity")); // NOI18N
        jBtnNew.setIcon(resourceMap.getIcon("jBtnNew.icon")); // NOI18N
        jBtnNew.setText(resourceMap.getString("jBtnNew.text")); // NOI18N
        jBtnNew.setName("jBtnNew"); // NOI18N
        jBtnNew.setPreferredSize(new java.awt.Dimension(110, 30));
        jPnlBottom.add(jBtnNew);

        jBtnSelect.setAction(actionMap.get("selectEntity")); // NOI18N
        jBtnSelect.setIcon(resourceMap.getIcon("jBtnSelect.icon")); // NOI18N
        jBtnSelect.setText(resourceMap.getString("jBtnSelect.text")); // NOI18N
        jBtnSelect.setName("jBtnSelect"); // NOI18N
        jBtnSelect.setPreferredSize(new java.awt.Dimension(110, 30));
        jPnlBottom.add(jBtnSelect);

        getContentPane().add(jPnlBottom, java.awt.BorderLayout.SOUTH);

        jPnlRigth.setName("jPnlRigth"); // NOI18N
        jPnlRigth.setPreferredSize(new java.awt.Dimension(20, 240));

        javax.swing.GroupLayout jPnlRigthLayout = new javax.swing.GroupLayout(jPnlRigth);
        jPnlRigth.setLayout(jPnlRigthLayout);
        jPnlRigthLayout.setHorizontalGroup(
            jPnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 20, Short.MAX_VALUE)
        );
        jPnlRigthLayout.setVerticalGroup(
            jPnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 217, Short.MAX_VALUE)
        );

        getContentPane().add(jPnlRigth, java.awt.BorderLayout.LINE_END);

        jPnlLeft.setName("jPnlLeft"); // NOI18N
        jPnlLeft.setPreferredSize(new java.awt.Dimension(20, 240));

        javax.swing.GroupLayout jPnlLeftLayout = new javax.swing.GroupLayout(jPnlLeft);
        jPnlLeft.setLayout(jPnlLeftLayout);
        jPnlLeftLayout.setHorizontalGroup(
            jPnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 20, Short.MAX_VALUE)
        );
        jPnlLeftLayout.setVerticalGroup(
            jPnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 217, Short.MAX_VALUE)
        );

        getContentPane().add(jPnlLeft, java.awt.BorderLayout.LINE_START);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * 
     */
    @Action
    public void newEntity() {
        this.controllerEntityView.newEntity();
    }

    /**
     * 
     */
    @Action
    public void edtiEntity() {
        this.controllerEntityView.editEntity();
    }

    /**
     * 
     */
    @Action
    public void removeEntity() {
        this.controllerEntityView.removeEntity();
    }

    /**
     * 
     */
    @Action
    public void closeForm() {
        this.controllerEntityView.closeForm();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtnClose;
    private javax.swing.JButton jBtnEdit;
    private javax.swing.JButton jBtnNew;
    private javax.swing.JButton jBtnRemove;
    private javax.swing.JButton jBtnSelect;
    private javax.swing.JPanel jPnlBottom;
    private javax.swing.JPanel jPnlCenter;
    private javax.swing.JPanel jPnlLeft;
    private javax.swing.JPanel jPnlLeftsearchBar;
    private javax.swing.JPanel jPnlRigth;
    private javax.swing.JPanel jPnlRigthSearchBar;
    private javax.swing.JPanel jPnlTop;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXTable jTableEntities;
    private org.jdesktop.swingx.JXHeader jXEntityHeader;
    private org.jdesktop.swingx.JXFindBar jXFindBar1;
    // End of variables declaration//GEN-END:variables

    /**
     * @return table
     */
    public JXTable getjTableEntities() {
        return this.jTableEntities;
    }

    /**
     * @return Btn Edit
     */
    public JButton getjBtnEdit() {
        return this.jBtnEdit;
    }

    /**
     * @return Btn New entity
     */
    public JButton getjBtnNew() {
        return this.jBtnNew;
    }

    /**
     * @return Btn Remove
     */
    public JButton getjBtnRemove() {
        return this.jBtnRemove;
    }

    @Action
    public void selectEntity() {
        this.controllerEntityView.selectEntity();
    }

    /**
     * @return the jBtnClose
     */
    public javax.swing.JButton getjBtnClose() {
        return jBtnClose;
    }

    /**
     * @return the jBtnSelect
     */
    public javax.swing.JButton getjBtnSelect() {
        return jBtnSelect;
    }

    /**
     * @return the jXEntityHeader
     */
    public org.jdesktop.swingx.JXHeader getJXEntityHeader() {
        return jXEntityHeader;
    }

    /**
     * @param jXEntityHeader the jXEntityHeader to set
     */
    public void setJXEntityHeader(org.jdesktop.swingx.JXHeader jXEntityHeader) {
        this.jXEntityHeader = jXEntityHeader;
    }
}
